Performance.registerGroup({
	name: "js.iterate"
});

Performance.registerTest({
	group: "js.iterate",
	name: "array: for",
	args: [2500, 5000, 10000, 15000],
	
	run: function(arg) {
		var arr = ["a", "b", "c", "d", "e", "f", "g"],
			len = arr.length, count = 0;
		
		while(arg--) {
			for(var i = 0; i < len; i++) {
				if(arr[i]) { count++; }
			}
		}
	}
});

Performance.registerTest({
	group: "js.iterate",
	name: "array: for -big",
	args: [25000, 50000, 100000, 150000],
	
	run: function(arg) {
		var arr = [], count = 0;
		
		for(var i = 0; i < 30; i++) {
			arr.push("direct.long.path" + i);
		}
		
		while(arg--) {
			for(var i = 0, l = arr.length; i < l; i++) {
				if(arr[i]) { count++; }
			}
		}
	}
});

Performance.registerTest({
	group: "js.iterate",
	name: "array: yuiEach",
	args: [2500, 5000, 10000, 15000],
	
	run: function(arg) {
		var arr = ["a", "b", "c", "d", "e", "f", "g"],
			count = 0;
		
		function loop(v) {
			if(v) { count++; }
		}
		
		while(arg--) {
			Array.yuiEach(arr, loop);
		}
	}
});

Performance.registerTest({
	group: "js.iterate",
	name: "array: each -outside",
	args: [2500, 5000, 10000, 15000],
	
	run: function(arg) {
		var arr = ["a", "b", "c", "d", "e", "f", "g"],
			count = 0;
		
		function loop(v) {
			if(v) { count++; }
		}
		
		while(arg--) {
			Array.each(arr, loop);
		}
	}
});

Performance.registerTest({
	group: "js.iterate",
	name: "array: each -inside",
	args: [2500, 5000, 10000, 15000],
	
	run: function(arg) {
		var arr = ["a", "b", "c", "d", "e", "f", "g"],
			count = 0;
		
		while(arg--) {
			Array.each(arr, function(v) {
				if(v) { count++; }
			});
		}
	}
});

Performance.registerTest({
	group: "js.iterate",
	name: "object: for-in",
	args: [2500, 5000, 10000, 15000],
	
	run: function(arg) {
		var hash = {a: "a", b: "b", c: "c", d: "d", e: "e", f: "f", g: "g"};
			count = 0;
		
		while(arg--) {
			for(var k in hash) {
				if(hash[k]) { count++; }
			}
		}
	}
});

Performance.registerTest({
	group: "js.iterate",
	name: "object: for",
	args: [2500, 5000, 10000, 15000],
	
	run: function(arg) {
		var hash = {a: "a", b: "b", c: "c", d: "d", e: "e", f: "f", g: "g"};
			count = 0;
		
		while(arg--) {
			var keys = Object.keys(hash),
				len = keys.length;
			
			for(var i = 0; i < len; i++) {
				if(hash[keys[i]]) { count++; }
			}
		}
	}
});

Performance.registerTest({
	group: "js.iterate",
	name: "object: yuiEach",
	args: [2500, 5000, 10000, 15000],
	
	run: function(arg) {
		var hash = {a: "a", b: "b", c: "c", d: "d", e: "e", f: "f", g: "g"};
			count = 0;
		
		while(arg--) {
			Object.yuiEach(hash, function(v) {
				if(v) { count++; }
			});
		}
	}
});

Performance.registerTest({
	group: "js.iterate",
	name: "object: each",
	args: [2500, 5000, 10000, 15000],
	
	run: function(arg) {
		var hash = {a: "a", b: "b", c: "c", d: "d", e: "e", f: "f", g: "g"};
			count = 0;
		
		while(arg--) {
			Object.each(hash, function(v) {
				if(v) { count++; }
			});
		}
	}
});